package demo;

import com.lijinjiang.beautyeye.BeautyEyeLNFHelper;

import javax.swing.*;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

/**
 * @ClassName demo.JButtonDemo
 * @Description TODO
 * @Author Li
 * @Date 2022/8/27 0:51
 * @ModifyDate 2022/8/27 0:51
 * @Version 1.0
 */
public class JToolBarDemo {
    public static void main(String[] args) {
        try {
            BeautyEyeLNFHelper.frameBorderStyle = BeautyEyeLNFHelper.FrameBorderStyle.generalNoTranslucencyShadow;
            com.lijinjiang.beautyeye.BeautyEyeLNFHelper.launchBeautyEyeLNF();
            //UIManager.put("RootPane.setupButtonVisible", false); // 隐藏设置按钮
            UIManager.put("SplitPaneDivider.TOUCH_DECORATED_BUTTON_W", 0); // 设置分隔线装饰按钮的宽度，设置为 0，则不显示该装饰按钮
        } catch (Exception e) {
        }

        JFrame frame = new JFrame("demo.JToolBarDemo"); // 创建一个JFrame对象
        JPanel panel = new JPanel(); // 创建面板

        panel.setLayout(null);
        /* 1.消息对话框（提示消息） */
        JButton button1 = new JButton("showMessageDialog(提示)");
        button1.setBounds(100, 20, 180, 30);
        button1.addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                JOptionPane.showMessageDialog(frame, "这是一条提示信息",
                        "标题1", JOptionPane.INFORMATION_MESSAGE);
            }
        });

        panel.add(button1);


        frame.add(panel);
        createToolBar(frame);
        frame.setBounds(100, 100, 400, 300);
        frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); // 设置窗口关闭后结束运行
        frame.setLocationRelativeTo(null);
        frame.setVisible(true); // 设置窗口可见
    }

    private static void createToolBar(JFrame frame) {
        JToolBar toolBar = new JToolBar(); // 工具栏
        String path = JToolBarDemo.class.getResource("/").getPath();
        // 运行操作
        JButton closeBtn = new JButton("Close", new ImageIcon(path + "images/close.png"));
        closeBtn.setFocusable(false);

        toolBar.add(closeBtn);
        toolBar.addSeparator();
        toolBar.setFloatable(false); // 设置不可拖动
        frame.add(toolBar, BorderLayout.PAGE_START);
    }
}
